from django.db import models

from common.models import House


class BaseModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, null=True)
    update_time = models.DateTimeField(auto_now=True, null=True)

    class Meta:
        abstract = True


class HouseImage(BaseModel, models.Model):
    url = models.ImageField(max_length=256, null=False, upload_to='house_image')  # 图片的路径
    # 多对一关联房屋
    house = models.ForeignKey(House, related_name='house_image', on_delete=models.CASCADE, null=True)

    class Meta:
        db_table = 'ihome_house_image'



